All Questions
7 questions
0votes
0answers
32views
API design for precomputation cache [closed]
In my numeric code library I have a function totient_sum that depends on an expensive one-time precomputation totsum_range = [...], then different calls to totient_sum(n) are quick. There are several ...
1vote
2answers
196views
Should I add functionality by adding a new method to a class - or should I "register" the new functionality into a data structure?
I have one large class that computes ~50 different metrics (each metric has no side effects). My code is similar to this: class ReportingMetrics: def __init__(self, data:pd.DataFrame, config:dict)...
-1votes
1answer
210views
Refactoring: Pythonic way of reducing the subclasses?
background: so, I am working on an NLP problem. where I need to extract different types of features based on different types of context from text documents. and I currently have a setup where there is ...
1vote
4answers
883views
Design pattern for a function class
I have been experimenting with the idea of function classes as explained in this article and Composition applied to function dependencies as described in the following questions: https://stackoverflow....
1vote
1answer
198views
Representing mathematical tree structures using software in a compact manner
In my work I frequently come across systems of interdependent equations. I have contrived a toy example as follows. The terminal values w, x, y and z are given: e(y) = A+B A(y) = x*log(y)+y^z B(y) =...
2votes
3answers
4kviews
Function Overloading in Python
My book says that function overloading is not possible in python but it asks me questions like: WAP to find out the volume of a cube,cuboid and cylinder using function overloading. Do I have to ...
36votes
7answers
12kviews
Functional programming compared to OOP with classes
I have been interested in some of the concepts of functional programming lately. I have used OOP for some time now. I can see how I would build a fairly complex app in OOP. Each object would know how ...